const Joi = require("joi");
const moment = require("moment");
/**
 * 签到相关
 */
module.exports = class SignController extends colpu.Controller {
  async getSign(ctx) {
    await ctx.validateAsync({
      query: {
        uid: Joi.string().required(),
      },
      status: 10001,
    });
    try {
      const res = await this.service.sign.getYesterdaySign(ctx.query.uid);
      ctx.respondEncrypt(res);
    } catch (err) {
      ctx.throw(500, err.message);
    }
  }
  async updateSign(ctx) {
    await ctx.validateAsync({
      body: {
        uid: Joi.string().required(),
      },
      status: 10001,
    });
    try {
      const res = await this.service.sign.updateSign(ctx.request.body.uid);
      ctx.respondEncrypt(res);
    } catch (err) {
      ctx.throw(500, err.message);
    }
  }
};
